import { BASE_API, FILE_API } from '@/config/index.js'
const http = uni.$u.http

// 创建用户
export const createUser = (data, config = {}) => http.post('/users', data, config)

// 登录
export const getToken = (data, config = {}) => http.post('/token', data, config)

// 获取用户信息
export const getInfos = (params = {}) => http.get('/users/me', { params })

// 创建任务
export const setTask = (id, data, config = {}) => http.post(`/users/${id}/tasks/`, data, config)

// 上传图片 需拼接/${uid}/${tid}
export const uploadImage = `${BASE_API}/uploadimage`
// export const uploadImgs = (uid, tid, data, config = {}) => http.post(`/uploadimage/${uid}/${tid}`, data, config)

// 任务列表
export const getTask = (params = {}) => http.get('/tasks/', { params })

// 变更任务状态
export const uptTask = (id, data, config = {}) => http.post(`/tasks/${id}`, data, config)

// 上传图片(通用简易版)
export const uploads = `${BASE_API}/upload`

// 图片的预览前缀
export const file = FILE_API
// export const file = 'http://lctest.ai.xee.link/'

// 料槽任务提交
export const setRecords = (data, config = {}) => http.post('/feedslot_records/', data, config)

// 料槽记录列表
export const getRecords = (params = {}) => http.get('/feedslot_records/', { params })

// 根据id查询料槽记录列表
export const getRecordsById = (params = {}) => http.get('/feedslot_records_by_id/', { params })

// 修改密码
export const setChangePassword = (data, config = {}) => http.post('/change-password', data, config)

// 料槽记录每日统计
export const getRecordParams = (params = {}) => http.get('/feedslot_daily_stats/', { params })

// 消毒任务每日统计
export const getTaskParams = (params = {}) => http.get('/tasks/statistics/', { params })

// 背膘任务提交
export const setHugRecords = (data, config = {}) => http.post('/hugback_records/', data, config)

// 背膘记录列表
export const getHugRecords = (params = {}) => http.get('/hugback_records/', { params })

// 根据id查询背膘记录列表
export const getHugRecordsById = (params = {}) => http.get('/hugback_records_by_id/', { params })

// 阿里云上传
export const setOssUpload = `${BASE_API}/notify-upload`

// 查看栋舍料槽任务统计
export const getRecordsAsBuild = (params = {}) => http.get('/feedslot_daily_stats/', {params})